import 'package:flutter/material.dart';
import 'package:flutterdemo01/demo3/pages/FirstFoodPage.dart';
import 'package:flutterdemo01/demo3/pages/FirstHomePage.dart';
import 'package:flutterdemo01/demo3/pages/FirstMyPage.dart';
import 'package:flutterdemo01/demo3/pages/FirstNewsPage.dart';
import 'package:flutterdemo01/demo3/pages/FirstWeahterPage.dart';

main() {
  runApp(FirstApp());
}

class FirstApp extends StatefulWidget {
  const FirstApp({Key? key}) : super(key: key);

  @override
  _FirstAppState createState() => _FirstAppState();
}

class _FirstAppState extends State<FirstApp> {
  int _chooseIndex = 0;

  List _pages = [
    FirstHomePage(),
    FirstNewsPage(),
    FirstFoodPage(),
    FirstWeatherPage(),
    FirstMyPage()
  ];

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(primaryColor: Colors.black),
      home: Scaffold(
        // appBar: AppBar(title: Text('appbar'),),
        body: _pages[_chooseIndex],
        bottomNavigationBar: BottomNavigationBar(
          currentIndex: _chooseIndex,
          //backgroundColor: Colors.tealAccent,
          type: BottomNavigationBarType.fixed,
          unselectedItemColor: Colors.black,
          selectedItemColor: Colors.purpleAccent,
          items: [
            BottomNavigationBarItem(icon: Icon(Icons.home), label: '首页'),
            BottomNavigationBarItem(
                icon: Icon(Icons.message_sharp), label: '新闻'),
            BottomNavigationBarItem(
                icon: Icon(Icons.emoji_food_beverage_outlined), label: '美食'),
            BottomNavigationBarItem(
                icon: Icon(Icons.center_focus_weak_rounded), label: '天气'),
            BottomNavigationBarItem(icon: Icon(Icons.person), label: '我的'),
          ],
          onTap: (position) {
            setState(() {
              _chooseIndex = position;
            });
          },
        ),
      ),
    );
  }
}
